//
//  HLSettingPrivacyViewController.m
//  YueYue
//
//  Created by hulu001 on 2023/5/19.
//

#import "HLSettingPrivacyViewController.h"
#import "HLBlackListViewController.h"
#import "HLMineCell.h"

@interface HLSettingPrivacyViewController ()

@end

@implementation HLSettingPrivacyViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = HLBackgroundColor;
}

- (void)setupNavigationItems
{
    [super setupNavigationItems];
    self.title = @"隐私";
}

- (void)initTableView
{
    [super initTableView];
    
    [self.datasources addObjectsFromArray:[HLMineCellModel cellWithSettingPrivacy]];
    
    self.tableView.backgroundColor = HLBackgroundColor;
    [self.tableView registerClass:[HLMineCell class] forCellReuseIdentifier:[HLMineCell identifyCell]];
    
}

- (UIStatusBarStyle)preferredStatusBarStyle
{
    return UIStatusBarStyleDarkContent;
}

- (UIImage *)qmui_navigationBarBackgroundImage
{
    return [UIImage qmui_imageWithColor:HLBackgroundColor];
}

- (nullable UIColor *)qmui_navigationBarTintColor
{
    return UIColorBlack;
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return self.datasources.count;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    NSArray *sections = self.datasources[section];
    return sections.count;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    HLMineCell *cell = [tableView dequeueReusableCellWithIdentifier:[HLMineCell identifyCell]];
    cell.model = self.datasources[indexPath.section][indexPath.row];
    return cell;
}


- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{
    UIView *footerView = [[UIView alloc] init];
    footerView.backgroundColor = HLBackgroundColor;
    if (section == 0){
        UILabel *titleLabel = [[UILabel alloc] init];
        titleLabel.font = UIFontMake(13);
        titleLabel.textColor = HLTextColor2;
        titleLabel.text = @"系统权限";
        [footerView addSubview:titleLabel];
        [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(16);
            make.top.mas_equalTo(20);
            make.bottom.mas_equalTo(-12);
        }];
    }
    
    return footerView;
}

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
    return 52;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    HLMineCellModel *model = self.datasources[indexPath.section][indexPath.row];
    
    switch (model.cellSpot) {
        case HLMineCellSpotSettingPrivacyBlack:
        {
            HLBlackListViewController *blackVC = [[HLBlackListViewController alloc] init];
            [self.navigationController pushViewController:blackVC animated:YES];
        }
            break;
            
        default:
            break;
    }
}

@end
